package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SystemDictionaryItem;
import cn.wolfcode.crm.mapper.SystemDictionaryItemMapper;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.ISystemDictionaryItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictionaryItemServiceImpl implements ISystemDictionaryItemService{
	@Autowired
	private SystemDictionaryItemMapper systemDictionaryItemMapper;
	@Override
	public void insert(SystemDictionaryItem systemDictionaryItem) {
		systemDictionaryItemMapper.insert(systemDictionaryItem);
	}

	@Override
	public void delete(Long id) {
		systemDictionaryItemMapper.delete(id);
	}

	@Override
	public void update(SystemDictionaryItem systemDictionaryItem) {
		systemDictionaryItemMapper.update(systemDictionaryItem);
	}

	@Override
	public SystemDictionaryItem select(Long id) {
		SystemDictionaryItem systemDictionaryItem = systemDictionaryItemMapper.select(id);
		return systemDictionaryItem;
	}

	@Override
	public List<SystemDictionaryItem> list() {
		List<SystemDictionaryItem> list = systemDictionaryItemMapper.list();
		return list;
	}

	public PageInfo<SystemDictionaryItem> query(QueryObject qo) {
		PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),"sequence DESC");
        List<SystemDictionaryItem> systemDictionaryItems = systemDictionaryItemMapper.selectForList(qo);
        return new PageInfo<>(systemDictionaryItems);
	}

	public List<SystemDictionaryItem> selectBySystemDictionarySn(String systemDictionarySn) {
		return systemDictionaryItemMapper.selectBySystemDictionarySn(systemDictionarySn);
	}


}
